<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/jsp/include/head.jsp"/>
</head>
<body>

<ol class="breadcrumb">
    <li><strong>当前位置： </strong>系统监控</li>
    <li class="active">登录日志</li>
</ol>


<div class="panel panel-info">
    <div class="panel-heading">
        <h3 style="display: inline-block" class="panel-title">查询</h3>
    </div>
    <div class="panel-body">
        <form id="form_search" class="form-horizontal row">

            <div class="form-group col-sm-5">
                <label class="col-sm-4  control-label  ">登&nbsp;&nbsp;录&nbsp;&nbsp;名：</label>
                <div class="col-sm-8">
                    <input class="form-control " type="text" name="loginName">
                </div>
            </div>

            <div class="form-group col-sm-5">
                <label class="col-sm-4  control-label  ">IP&nbsp;&nbsp;地&nbsp;&nbsp;址：</label>
                <div class="col-sm-8">
                    <input class="form-control " type="text" name="ip">
                </div>
            </div>

            <div class="form-group col-sm-5">
                <label class="col-sm-4  control-label  ">登录时间：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <div class="input-group date form_date timeInput">
                       <span class="input-group-addon">
                          <span class="glyphicon glyphicon-calendar"></span>
                       </span>
                            <input class="form-control " type="text" name="startTime">
                        </div>
                        <span class="input-group-addon"
                              style="width: auto;padding-right: 3px;padding-left: 3px;border-width: 0px;background-color: transparent">
                          <span>~</span>
                       </span>
                        <div class="input-group date form_date timeInput">
                       <span class="input-group-addon">
                          <span class="glyphicon glyphicon-calendar"></span>
                       </span>
                            <input class="form-control " type="text" name="endTime">
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group col-sm-5">
                <label class="col-sm-4  control-label  ">登录结果：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="loginResult">
                        <option value="">&nbsp;</option>
                        <option value="0">失败</option>
                        <option value="1">成功</option>
                    </select>
                </div>
            </div>

            <div class="form-group col-sm-2">
                <div class="col-sm-8 col-sm-offset-4 ">
                    <button id="btn_search" type="button" class="btn btn-default "><span
                            class="glyphicon glyphicon-search"></span>&nbsp;查&nbsp;询&nbsp;</button>
                </div>
            </div>
        </form>

    </div>
</div>

<table id="table_data"></table>


<jsp:include page="/WEB-INF/jsp/include/footer.jsp"/>


<script>


    var $table_data = $('#table_data'), loginResult = {0: '失败', 1: '成功'};
    $("#btn_search").click(function () {
        $table_data.bootstrapTable('refresh');
    });
    $table_data.bootstrapTable({
        url: 'log/loginLog/select',
        striped: true,
        cache: false,
        sidePagination: 'server',
        pageSize: 10,
        pageList: [10, 20, 30, 40, 50, 100],
        pageNumber: 1,
        pagination: true,
        queryParams: function (params) {
            $.extend(params, $("#form_search").serializeObject());
            return params
        },
        columns: [
            {
                formatter: function (value, row, index) {
                    return index + 1
                }
            }, {
                field: 'loginName',
                title: '登录名'
            },
            {
                field: 'ip',
                title: 'IP地址'
            },
            {
                field: 'loginTime',
                title: '登录时间',
                formatter: function (value, row, index) {
                    return [
                        $.Helper.dataTimeHelper.int2DateTimeString(value)
                    ].join('');
                }
            },
            {
                field: 'loginResult',
                title: '登录结果',
                formatter: function (value, row, index) {
                    var s;
                    if (value == 1) {
                        s = '<button type="button"  class="btn btn-xs btn-default btn-success">成功</button>';
                    } else {
                        s = '<button type="button"  class="btn btn-xs btn-default btn-danger">失败</button>';
                    }
                    return [s].join('');
                }
            }

        ]
    });

    $.sysPlugin.initDateTimeInput();
    $.sysPlugin.initSimpleSelect2();
</script>
</body>
</html>
